package com.mousycoder.redis.controller;

import com.mousycoder.redis.RedisService;
import com.mousycoder.redis.service.BloomFilterService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * TODO
 *
 * @author mousycoder
 * @version 1.0
 * @date 2022/4/25 10:02 AM
 */
@RestController
public class BloomFilterController {

    @Resource
    private BloomFilterService bloomFilterService;

    @Resource
    private RedisService redisService;


    public static final String bloomFilterName = "isVipBloom";


    @RequestMapping("/bloom/idExists")
    public boolean ifExists(int id) {
        return bloomFilterService.userIdExists(id);
    }


    @RequestMapping("/bloom/redisIdExists")
    public boolean redisidExists(int id) {
        return redisService.bloomFilterExists(bloomFilterName, id);
    }

    @RequestMapping("/bloom/redisIdAdd")
    public boolean redisidAdd(int id) {
        return redisService.bloomFilterAdd(bloomFilterName, id);
    }


}
